package org.jeecg.modules.model.entity;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Date;
import java.math.BigDecimal;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.modules.enums.NodeTypeEnum;
import org.jeecg.modules.model.model.result.BimModelUnitResult;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * @Description: bim_model_unit
 * @Author: jeecg-boot
 * @Date:   2023-04-18
 * @Version: V1.0
 */
@Data
@TableName("bim_model_unit")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="bim_model_unit对象", description="bim_model_unit")
public class BimModelUnit implements Serializable {
    private static final long serialVersionUID = 1L;
	/**支节点/构件编码*/
	@Excel(name = "支节点/构件编码", width = 15)
    @ApiModelProperty(value = "支节点/构件编码")
    @TableId(type = IdType.ASSIGN_ID)
    private Long unitId;
	/**楼层编码*/
	@Excel(name = "楼层编码", width = 15)
    @ApiModelProperty(value = "楼层编码")
    private Integer floorId;
	/**楼栋编码*/
	@Excel(name = "楼栋编码", width = 15)
    @ApiModelProperty(value = "楼栋编码")
    private Integer buildId;
	/**名称*/
	@Excel(name = "名称", width = 15)
    @ApiModelProperty(value = "名称")
    private String name;
    /**标签编码*/
    @Excel(name = "标签编码", width = 15)
    @ApiModelProperty(value = "标签编码")
    private String tagCode;
    /**节点类型,1-支节点,2-构件节点*/
    @Excel(name = "节点类型,1-支节点,2-构件节点", width = 15)
    @ApiModelProperty(value = "节点类型,1-支节点,2-构件节点")
    private Integer nodeType;
    /**父节点*/
    @Excel(name = "父节点", width = 15)
    @ApiModelProperty(value = "父节点")
    private Long parentId;
    /**父节点全量,以逗号分割*/
    @Excel(name = "父节点全量,以逗号分割", width = 15)
    @ApiModelProperty(value = "父节点全量,以逗号分割")
    private String parentIds;
    /**bim模型原构件ID*/
	@Excel(name = "bim模型原构件ID", width = 15)
    @ApiModelProperty(value = "bim模型原构件ID")
    private String sourceBimId;
	/**bim模型原构件路径*/
	@Excel(name = "bim模型原构件路径", width = 15)
    @ApiModelProperty(value = "bim模型原构件路径")
    private String sourceDir;
	/**创建者*/
	@Excel(name = "创建者", width = 15)
    @ApiModelProperty(value = "创建者")
    private String createUser;
	/**创建时间*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
	/**删除(1:是,0:否)*/
	@Excel(name = "删除(1:是,0:否)", width = 15)
    @ApiModelProperty(value = "删除(1:是,0:否)")
    private Integer delFlag;

    @ApiModelProperty(hidden = true)
    @TableField(exist = false)
	private BimModelUnitResult unitResult;

	public BimModelUnitResult convertResult(){
	    if(ObjectUtil.isNull(unitResult)) {
            BimModelUnitResult unitResult = new BimModelUnitResult();
            unitResult.setBuildId(this.getBuildId());
            unitResult.setFloorId(this.getFloorId());
            unitResult.setName(this.getName());
            unitResult.setNodeType(this.getNodeType());
            unitResult.setUnitId(this.getUnitId());
            unitResult.setChildrens(new ArrayList<>());
            if(NodeTypeEnum.UNIT.getValue().equals(nodeType)){
                unitResult.setTagCode(this.getTagCode());
                unitResult.setSourceBimId(this.getSourceBimId());
                unitResult.setSourceDir(this.getSourceDir());
            }
            this.setUnitResult(unitResult);
        }
        return this.getUnitResult();
    }
}
